//
//  HRZHomeAdService.m
//  EMarket
//
//  Created by 石头 on 2018/8/28.
//  Copyright © 2018 好日子. All rights reserved.
//

#import "HRZHomeAdService.h"
// Controllers

// Models
#import "HRZHomeBigbrandModel.h"
#import "HRZHomeHotClassifyModel.h"
#import "HRZHomeThemeModel.h"
#import "HRZHomeCarouselModel.h"
#import "HRZGoodsClassifyDetailModel.h"
#import "HRZSearchThemeGoodsModel.h"
// Views

// Vendors

// Categories

// Others


@interface HRZHomeAdService ()

@end

@implementation HRZHomeAdService

+ (void)getBigbrandsSuccess:(void (^)(NSArray<HRZHomeBigbrandModel *> *))success
                    failure:(void (^)(NSString *))failure {
    
    HRZAPIRequest *request = [[HRZAPIRequest alloc] initWithAPIRequestType:kAPIRequestType_Get withSubPath:kBigbrandUrl];
    
    [HRZAPIClient execute:request];
    
    request.ServerSuce = ^(NSDictionary *sucObj) {
        NSArray * array = [HRZHomeBigbrandModel mj_objectArrayWithKeyValuesArray:sucObj];
        success(array);
    };
    
    request.ServerFail = ^(NSString *error) {
        failure(error);
    };
    
}

+ (void)getHotClassifySuccess:(void (^)(NSArray<HRZHomeHotClassifyModel *> *))success
                      failure:(void (^)(NSString *))failure {
    
    HRZAPIRequest *request = [[HRZAPIRequest alloc] initWithAPIRequestType:kAPIRequestType_Get withSubPath:kHotclassifyUrl];
    
    [HRZAPIClient execute:request];
    
    request.ServerSuce = ^(NSDictionary *sucObj) {
        NSArray * array = [HRZHomeHotClassifyModel mj_objectArrayWithKeyValuesArray:sucObj];
        success(array);
    };
    
    request.ServerFail = ^(NSString *error) {
        failure(error);
    };
}

+ (void)getThemeSuccess:(void (^)(NSArray<HRZHomeThemeModel *> *))success
                failure:(void (^)(NSString *))failure {
    
    HRZAPIRequest *request = [[HRZAPIRequest alloc] initWithAPIRequestType:kAPIRequestType_Get withSubPath:kThemeUrl];
    
    [HRZAPIClient execute:request];
    
    request.ServerSuce = ^(NSDictionary *sucObj) {
        NSArray * array = [HRZHomeThemeModel mj_objectArrayWithKeyValuesArray:sucObj];
        success(array);
    };
    
    request.ServerFail = ^(NSString *error) {
        failure(error);
    };
    
}

+ (void)getHomeCarouselSuccess:(void (^)(NSArray<HRZHomeCarouselModel *> *))success
                       failure:(void (^)(NSString *))failure {
    HRZAPIRequest *request = [[HRZAPIRequest alloc] initWithAPIRequestType:kAPIRequestType_Get withSubPath:kCarouselUrl];
    
    [HRZAPIClient execute:request];
    
    request.ServerSuce = ^(NSDictionary *sucObj) {
        NSArray * array = [HRZHomeCarouselModel mj_objectArrayWithKeyValuesArray:sucObj];
        success(array);
    };
    
    request.ServerFail = ^(NSString *error) {
        failure(error);
    };
}

+ (void)getThemeGoodsByTheme:(HRZSearchThemeGoodsModel *)model
                     success:(void (^)(NSArray<HRZGoodsClassifyDetailModel *> *))success
                     failure:(void (^)(NSString *))failure {
    NSMutableDictionary *params = [model mj_keyValues];
    HRZAPIRequest *request = [[HRZAPIRequest alloc] initWithAPIRequestType:kAPIRequestType_Get withSubPath:kThemeGoodsUrl];
    request.params = params;
    [HRZAPIClient execute:request];
    
    request.ServerSuce = ^(NSDictionary *sucObj) {
        NSArray * array = [HRZGoodsClassifyDetailModel mj_objectArrayWithKeyValuesArray:sucObj];
        success(array);
    };
    
    request.ServerFail = ^(NSString *error) {
        failure(error);
    };
}


@end
